package rauguelu.programaEventos;

import java.util.ArrayList;

import rauguelu.feria.tapas.Bares;
import rauguelu.items.MasInfObj;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class MasInfoMenu extends ListActivity {
 
//Mantenemos un Array de elementos en la que podremos guardar
//más información de la que mostraremos en el listado
ArrayList<MasInfObj> MasInfObj;
 

@Override
public void onCreate(Bundle savedInstanceState) {
 
    super.onCreate(savedInstanceState);

    setContentView(R.layout.masinfo_menu);
    ArrayList<MasInfObj> lista = new ArrayList<MasInfObj>();
    ImageView icon_turismo = (ImageView)findViewById(R.id.iconMasInfoMenuTurismo);
    
 

    MasInfObj evento1 = new MasInfObj("1","Alojamiento","","","alojamiento");
    
    MasInfObj evento2 = new MasInfObj("2","Climatología","Descubre el pronóstico del tiempo","","tiempo");
    
    MasInfObj evento3 = new MasInfObj("3","Teléfonos de Interés","","","telefonos");
    
    MasInfObj evento4 = new MasInfObj("4","Otras Actividades","","","actividades");    

//    MasInfObj evento5 = new MasInfObj("5","Aparcamiento festival","","","aparcamiento");
    
    MasInfObj evento6 = new MasInfObj("6","App desarrollada por:","","","desarrollo");
    
    MasInfObj evento7 = new MasInfObj("7","Contacto / Como llegar","","","aparcamiento");
    
    MasInfObj evento8 = new MasInfObj("8","Plano de establecimientos","","","establecimientos");

    lista.add(evento7);
    lista.add(evento8);
    lista.add(evento1);lista.add(evento2);lista.add(evento3);
    lista.add(evento4);//lista.add(evento5);
    lista.add(evento6);
    
    
    
    icon_turismo.setOnClickListener(new View.OnClickListener(){
	    public void onClick(View v){
	        Intent intent = new Intent();
	        intent.setAction(Intent.ACTION_VIEW);
	        intent.addCategory(Intent.CATEGORY_BROWSABLE);
	        intent.setData(Uri.parse("http://www.turismolaroda.com/"));
	        startActivity(intent);
	    }
	});
 	
	setListAdapter(new MenuAdapter(this, R.layout.masinfo_list_menu, lista));
}


	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
	    super.onListItemClick(l, v, position, id);
	
	    Intent intent = null;
	    
	    if(id ==  0){
	    	intent = new Intent(this,infoFestival.class);
		}else if(id ==  1){
	    	intent = new Intent(this,Bares.class);
		}else if(id ==  2){
	    	intent = new Intent(this,MasInfoItemsAlojamientos.class);
		}else if(id == 3){
			//intent = new Intent(this,MasInfoItemsEntradas.class);
			intent = new Intent(this,MasInfoClimatologia.class);
		}else if(id == 4){
			intent = new Intent(this,MasInfoItemsTelefonos.class);
		}else if(id == 5){
			intent = new Intent(this,MasInfoItemsActividades.class);
//		}else if(id == 5){
//			intent = new Intent(this,MasInfoMapaParking.class);
		}else if(id == 6){
			intent = new Intent(this,MasInfoDesarrollo.class);
		}else{
			intent = new Intent(this,infoFestival.class);
		}
	    
	 
	    startActivity(intent);
	}
	
	private class MenuAdapter extends ArrayAdapter<MasInfObj> {

		private ArrayList<MasInfObj> items;

		public MenuAdapter(Context context, int textViewResourceId,
				ArrayList<MasInfObj> items) {
			super(context, textViewResourceId, items);
			this.items = items;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View v = convertView;
			TextView CabeceraMasInfo = (TextView) findViewById(R.id.CabeceraMasInfo);
			
			
			Typeface font2= Typeface.createFromAsset(getAssets(), "VSVAB.TTF");
			Typeface font = Typeface.createFromAsset(getAssets(), "VSVBPSB.TTF");
			CabeceraMasInfo.setTypeface(font);
			
			if (v == null) {
				LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				v = vi.inflate(R.layout.masinfo_list_menu, null);
			}
			final MasInfObj evento = items.get(position);
			if (evento != null) {
				TextView nombre = (TextView) v.findViewById(R.id.nombre);
				ImageView iconMasInfoMenu = (ImageView) v.findViewById(R.id.iconMasInfoMenu);
		
				iconMasInfoMenu.setImageResource(getBaseContext().getResources().getIdentifier(evento.getIcono()+"", "drawable", getBaseContext().getPackageName()));
				
				nombre.setText(evento.getTitulo());
				nombre.setTypeface(font2);
				
			}
			return v;
		}
	}

}

